#pragma once
#include "FSMState.h"
#include "StringHash.h"
#include "ObjectId.h"
#include "collisionObserver.h"
#include "Subscriber.h"

class PhysicsBody;
class GfxText;

class GameState: public FSMState, public CollisionObserver
{
public:
	GameState(const ObjectId& stateId);
	~GameState(){}

	virtual void onEnter();
	virtual void onLeave();
	virtual void onFrame(real frametime, real timestep);

	virtual void CollisionEvent(const CollisionData& collision);
private:

	static const real SPEED_FACTOR;

	// Give a random direction to the ball.
	void randomizeBallDirection();
	void checkCombo(const ObjectId& objectId);

	PhysicsBody* m_ballBody;
	
	// Current ball speed.
	real m_ballSpeed;

	// Is there a power shot active?
	bool m_powerShot;

	Publisher<CollisionObserver>* m_collisionPublisher;
	SubscriberHelper<CollisionObserver> m_collisionSubscriber;

	// Text properties used by this state.
	GfxText* m_uiScore1;
	GfxText* m_uiScore2;
	GfxText* m_uiPowerShot;
};
